home *** CD-ROM | disk | FTP | other *** search
-
- Palette8 converts a 24-bpp bitmap to 8-bpp. It is invoked by:
-
- palette8 <infile> [<outfile>]
-
- If no output file is given, the input file is replaced. In any case, the
- output file is not written until the process is complete. The program can be
- aborted, if necessary, to avoid overwriting an existing file.
- The input file may be a Windows or OS/2 bitmap. The output file is an OS/2
- bitmap.
- During processing, the screen is updated to show its progress. (It may take a
- minute or two for the first update while the program reads the input bitmap
- and counts colors.)
-
- -----------------------------
-
- The algorithm selects pairs of colors from the image and substitutes one for
- the other. The substituted color is discarded. This process continues until
- there are 256 colors remaining.
-
- The difference between the input and output images is measured by:
- 1. the number of pels whose color is changed, and
- 2. the amount of change in the color.
- The goal is to minimize the difference.
-
- To implement this, a color is selected and the number of times it occurs in
- the image is examined. A second color is compared to the first and the
- difference in colors calculated.
- The error in changing the first color to the second is measured as the
- difference between the colors weighted by the number of pels that would change.
- If this is acceptable, all pels of the first color are changed to the second.
- The first color is eliminated.
-
- The "acceptable error" is, at first, chosen to be small. Within this
- tolerance, as many colors as possible are eliminated. If there are still excess
- colors, then the tolerance is increased and the process is repeated until only
- 256 colors remain.
-
- The algorithm produces images which contain only the colors from the original.
- This differs from other algorithms which match image colors to a predetermined
- color table which may have few appropriate colors and many extraneous colors.
- The algorithm also tends to preserve details in the image where just a few
- pels of one color might otherwise be overwhelmed by other, more popular, colors.
-
- The process is not fast. While there are excess colors, each is compared to
- every other color (unless it is eliminated early). In raytraced images, for
- example, it is not uncommon to have tens of thousands of colors which take
- longer to reduce than the time it took to render the original image!
-
- ---------------------------------
-
- This program is provided as shareware. A $10.00 registration donation would
- be appreciated. $15.00 will also get you the application source code. $25.00 will
- get you all the above plus the source code for the Bitmap class library. (The Bitmap
- class DLL, HPP, and INF files are available in OS2DF1 section 5.)
-
- Please remit to:
-
- William A. Leonard
- 29 Bow Street
- Jamestown, RI 02835
-
- The author will support the application via CompuServe: 70252,3144.
-
- The author will not be liable for any bug, error, omission,
- defect, deficiency, or nonconformity in this software. The author
- also disclaims all implied warranties, including without limitation
- warranties of merchantability, performance, and fitness for a
- particular purpose. This software is provided "as is" and the user
- assumes the entire risk as to its quality and performance.
-